package com.proyecto.track.utils;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class MD5Hash {
	
	public String hashearPass(String password)
	{
		return hashPassword(password);
	}
	
	private String hashPassword(String password) {
		String hashword = null;
		try {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update(password.getBytes());
		BigInteger hash = new BigInteger(1, md5.digest());
		hashword = hash.toString(16);

		} catch (NoSuchAlgorithmException nsae) {

		}
		return pad(hashword,32,'0');
		}
	
	
	private String pad(String s, int length, char pad) {
	  StringBuffer buffer = new StringBuffer(s);
	  while (buffer.length() < length) {
		  buffer.insert(0, pad);
	  }
	 return buffer.toString();
	}
}
